<!DOCTYPE html>


<html lang="zn-CH">


<head>
  <meta charset="utf-8" />
    
  <meta name="description" content="What I can do is to Do My Personal Best!" />
  
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
  <title>
    XmlRootElement的作用和用法 |  小熊的博客
  </title>
  <meta name="generator" content="hexo-theme-yilia-plus">
  
  <link rel="shortcut icon" href="http://www.cdn.adingxiong.com/b5363a06dc744d79a94021492bcefe27" />
  
  
<link rel="stylesheet" href="/blog/dist/main.css">

  
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/Shen-Yu/cdn/css/remixicon.min.css">

  
<link rel="stylesheet" href="/blog/css/custom.css">

  
  
<script src="https://cdn.jsdelivr.net/npm/pace-js@1.0.2/pace.min.js"></script>

  
  

  

<link rel="alternate" href="/blog/atom.xml" title="小熊的博客" type="application/atom+xml">
</head>

</html>

<body>
  <div id="app">
    <main class="content on">
      <section class="outer">
  <article id="post-XmlRootElement的作用和用法" class="article article-type-post" itemscope
  itemprop="blogPost" data-scroll-reveal>

  <div class="article-inner">
    
    <header class="article-header">
       
<h1 class="article-title sea-center" style="border-left:0" itemprop="name">
  XmlRootElement的作用和用法
</h1>
 

    </header>
    

    
    <div class="article-meta">
      <a href="/blog/2020/09/04/XmlRootElement%E7%9A%84%E4%BD%9C%E7%94%A8%E5%92%8C%E7%94%A8%E6%B3%95/" class="article-date">
  <time datetime="2020-09-04T08:28:25.000Z" itemprop="datePublished">2020-09-04</time>
</a>
      
      
      
<div class="word_count">
    <span class="post-time">
        <span class="post-meta-item-icon">
            <i class="ri-quill-pen-line"></i>
            <span class="post-meta-item-text"> Word count:</span>
            <span class="post-count">1.4k</span>
        </span>
    </span>

    <span class="post-time">
        &nbsp; | &nbsp;
        <span class="post-meta-item-icon">
            <i class="ri-book-open-line"></i>
            <span class="post-meta-item-text"> Reading time≈</span>
            <span class="post-count">8 min</span>
        </span>
    </span>
</div>

      
    </div>
    

    
    
    <div class="tocbot"></div>





    

    
    <div class="article-entry" itemprop="articleBody">
      
      

      
      <section id="nice" data-tool="mdnice编辑器" data-website="https://www.mdnice.com" style="font-size: 16px; padding: 0 10px; word-spacing: 0px; word-break: break-word; word-wrap: break-word; text-align: left; line-height: 1.25; color: #2b2b2b; font-family: Optima-Regular, Optima, PingFangTC-Light, PingFangSC-light, PingFangTC-light; letter-spacing: 2px; background-image: linear-gradient(90deg, rgba(50, 0, 0, 0.04) 3%, rgba(0, 0, 0, 0) 3%), linear-gradient(360deg, rgba(50, 0, 0, 0.04) 3%, rgba(0, 0, 0, 0) 3%); background-size: 20px 20px; background-position: center center;"><h3 data-tool="mdnice编辑器" style="padding: 0px; color: black; font-size: 17px; font-weight: bold; text-align: center; position: relative; margin-top: 20px; margin-bottom: 20px;"><span class="prefix" style="display: none;"></span><span class="content" style="border-bottom: 2px solid RGBA(79, 177, 249, .65); color: #2b2b2b; padding-bottom: 2px;"><span style="width: 30px; height: 30px; display: block; background-image: url(https://my-wechat.mdnice.com/fullstack-2.png); background-position: center; background-size: 30px; margin: auto; opacity: 1; background-repeat: no-repeat; margin-bottom: -8px;"></span>手动封装实体类转换成xml</span><span class="suffix" style="display: none;"></span></h3>
<p data-tool="mdnice编辑器" style="padding-top: 8px; padding-bottom: 8px; line-height: 26px; color: #2b2b2b; margin: 10px 0px; letter-spacing: 2px; font-size: 14px; word-spacing: 2px;">实体类</p>
<pre class="custom" data-tool="mdnice编辑器" style="margin-top: 10px; margin-bottom: 10px; border-radius: 5px; box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;"><span style="display: block; background: url(https://my-wechat.mdnice.com/point.png); height: 30px; width: 100%; background-size: 40px; background-repeat: no-repeat; background-color: #1E1E1E; margin-bottom: -7px; border-radius: 5px; background-position: 10px 10px;"></span><code class="hljs" style="overflow-x: auto; padding: 16px; color: #DCDCDC; display: -webkit-box; font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; font-size: 12px; -webkit-overflow-scrolling: touch; letter-spacing: 0px; padding-top: 15px; background: #1E1E1E; border-radius: 5px;"><span class="hljs-keyword" style="color: #569CD6; line-height: 26px;">import</span>&nbsp;javax.xml.bind.JAXBContext;<br><span class="hljs-keyword" style="color: #569CD6; line-height: 26px;">import</span>&nbsp;javax.xml.bind.JAXBException;<br><span class="hljs-keyword" style="color: #569CD6; line-height: 26px;">import</span>&nbsp;javax.xml.bind.Marshaller;<br><span class="hljs-keyword" style="color: #569CD6; line-height: 26px;">import</span>&nbsp;javax.xml.bind.annotation.XmlElement;<br><span class="hljs-keyword" style="color: #569CD6; line-height: 26px;">import</span>&nbsp;javax.xml.bind.annotation.XmlRootElement;<br><br><span class="hljs-comment" style="color: #57A64A; font-style: italic; line-height: 26px;">/**<br>&nbsp;*&nbsp;<span class="hljs-doctag" style="color: #608B4E; line-height: 26px;">@ClassName</span>&nbsp;RequetsXml<br>&nbsp;*&nbsp;<span class="hljs-doctag" style="color: #608B4E; line-height: 26px;">@Description</span>&nbsp;TODO<br>&nbsp;*&nbsp;<span class="hljs-doctag" style="color: #608B4E; line-height: 26px;">@Author</span>&nbsp;xiongchao<br>&nbsp;*&nbsp;<span class="hljs-doctag" style="color: #608B4E; line-height: 26px;">@Date</span>&nbsp;2020/7/14&nbsp;10:23<br>&nbsp;**/</span><br><br><span class="hljs-meta" style="color: #9B9B9B; line-height: 26px;">@XmlRootElement</span>(name&nbsp;=&nbsp;<span class="hljs-string" style="color: #D69D85; line-height: 26px;">"request"</span>)<br><span class="hljs-keyword" style="color: #569CD6; line-height: 26px;">public</span>&nbsp;<span class="hljs-class" style="color: #B8D7A3; line-height: 26px;"><span class="hljs-keyword" style="color: #569CD6; line-height: 26px;">class</span>&nbsp;<span class="hljs-title" style="color: #DCDCDC; line-height: 26px;">RequetsXml</span>&nbsp;</span>{<br><br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="hljs-meta" style="color: #9B9B9B; line-height: 26px;">@XmlElement</span>(name&nbsp;=&nbsp;<span class="hljs-string" style="color: #D69D85; line-height: 26px;">"casefile"</span>)<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="hljs-keyword" style="color: #569CD6; line-height: 26px;">private</span>&nbsp;CaseFile&nbsp;caseFile;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="hljs-meta" style="color: #9B9B9B; line-height: 26px;">@XmlElement</span>(name&nbsp;=&nbsp;<span class="hljs-string" style="color: #D69D85; line-height: 26px;">"uploaded-file-id"</span>)<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="hljs-keyword" style="color: #569CD6; line-height: 26px;">private</span>&nbsp;String&nbsp;fileId;<br><br><br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="hljs-function" style="color: #DCDCDC; line-height: 26px;"><span class="hljs-keyword" style="color: #569CD6; line-height: 26px;">public</span>&nbsp;<span class="hljs-keyword" style="color: #569CD6; line-height: 26px;">void</span>&nbsp;<span class="hljs-title" style="color: #DCDCDC; line-height: 26px;">setCaseFile</span><span class="hljs-params" style="color: #DCDCDC; line-height: 26px;">(CaseFile&nbsp;caseFile)</span>&nbsp;</span>{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="hljs-keyword" style="color: #569CD6; line-height: 26px;">this</span>.caseFile&nbsp;=&nbsp;caseFile;<br>&nbsp;&nbsp;&nbsp;&nbsp;}<br><br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="hljs-function" style="color: #DCDCDC; line-height: 26px;"><span class="hljs-keyword" style="color: #569CD6; line-height: 26px;">public</span>&nbsp;<span class="hljs-keyword" style="color: #569CD6; line-height: 26px;">void</span>&nbsp;<span class="hljs-title" style="color: #DCDCDC; line-height: 26px;">setFileId</span><span class="hljs-params" style="color: #DCDCDC; line-height: 26px;">(String&nbsp;fileId)</span>&nbsp;</span>{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="hljs-keyword" style="color: #569CD6; line-height: 26px;">this</span>.fileId&nbsp;=&nbsp;fileId;<br>&nbsp;&nbsp;&nbsp;&nbsp;}<br><br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="hljs-keyword" style="color: #569CD6; line-height: 26px;">private</span>&nbsp;<span class="hljs-keyword" style="color: #569CD6; line-height: 26px;">static</span>&nbsp;<span class="hljs-class" style="color: #B8D7A3; line-height: 26px;"><span class="hljs-keyword" style="color: #569CD6; line-height: 26px;">class</span>&nbsp;<span class="hljs-title" style="color: #DCDCDC; line-height: 26px;">CaseFile</span></span>{<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="hljs-keyword" style="color: #569CD6; line-height: 26px;">private</span>&nbsp;String&nbsp;name;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="hljs-meta" style="color: #9B9B9B; line-height: 26px;">@XmlElement</span>(name&nbsp;=&nbsp;<span class="hljs-string" style="color: #D69D85; line-height: 26px;">"isTmpFile"</span>)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="hljs-keyword" style="color: #569CD6; line-height: 26px;">private</span>&nbsp;<span class="hljs-keyword" style="color: #569CD6; line-height: 26px;">boolean</span>&nbsp;isTmpFile;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="hljs-meta" style="color: #9B9B9B; line-height: 26px;">@XmlElement</span>(name&nbsp;=&nbsp;<span class="hljs-string" style="color: #D69D85; line-height: 26px;">"modify-timestamp"</span>)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="hljs-keyword" style="color: #569CD6; line-height: 26px;">private</span>&nbsp;String&nbsp;modifyTimStamp;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="hljs-meta" style="color: #9B9B9B; line-height: 26px;">@XmlElement</span>(name&nbsp;=&nbsp;<span class="hljs-string" style="color: #D69D85; line-height: 26px;">"sdb-group-id"</span>)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="hljs-keyword" style="color: #569CD6; line-height: 26px;">private</span>&nbsp;Integer&nbsp;groupId;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="hljs-meta" style="color: #9B9B9B; line-height: 26px;">@XmlElement</span>(name&nbsp;=&nbsp;<span class="hljs-string" style="color: #D69D85; line-height: 26px;">"source-system-id"</span>)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="hljs-keyword" style="color: #569CD6; line-height: 26px;">private</span>&nbsp;Integer&nbsp;sourceId;<br><br><br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="hljs-function" style="color: #DCDCDC; line-height: 26px;"><span class="hljs-keyword" style="color: #569CD6; line-height: 26px;">public</span>&nbsp;<span class="hljs-keyword" style="color: #569CD6; line-height: 26px;">void</span>&nbsp;<span class="hljs-title" style="color: #DCDCDC; line-height: 26px;">setName</span><span class="hljs-params" style="color: #DCDCDC; line-height: 26px;">(String&nbsp;name)</span>&nbsp;</span>{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="hljs-keyword" style="color: #569CD6; line-height: 26px;">this</span>.name&nbsp;=&nbsp;name;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br><br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="hljs-function" style="color: #DCDCDC; line-height: 26px;"><span class="hljs-keyword" style="color: #569CD6; line-height: 26px;">public</span>&nbsp;<span class="hljs-keyword" style="color: #569CD6; line-height: 26px;">void</span>&nbsp;<span class="hljs-title" style="color: #DCDCDC; line-height: 26px;">setTmpFile</span><span class="hljs-params" style="color: #DCDCDC; line-height: 26px;">(<span class="hljs-keyword" style="color: #569CD6; line-height: 26px;">boolean</span>&nbsp;tmpFile)</span>&nbsp;</span>{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;isTmpFile&nbsp;=&nbsp;tmpFile;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br><br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="hljs-function" style="color: #DCDCDC; line-height: 26px;"><span class="hljs-keyword" style="color: #569CD6; line-height: 26px;">public</span>&nbsp;<span class="hljs-keyword" style="color: #569CD6; line-height: 26px;">void</span>&nbsp;<span class="hljs-title" style="color: #DCDCDC; line-height: 26px;">setModifyTimStamp</span><span class="hljs-params" style="color: #DCDCDC; line-height: 26px;">(String&nbsp;modifyTimStamp)</span>&nbsp;</span>{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="hljs-keyword" style="color: #569CD6; line-height: 26px;">this</span>.modifyTimStamp&nbsp;=&nbsp;modifyTimStamp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="hljs-function" style="color: #DCDCDC; line-height: 26px;"><span class="hljs-keyword" style="color: #569CD6; line-height: 26px;">public</span>&nbsp;<span class="hljs-keyword" style="color: #569CD6; line-height: 26px;">void</span>&nbsp;<span class="hljs-title" style="color: #DCDCDC; line-height: 26px;">setGroupId</span><span class="hljs-params" style="color: #DCDCDC; line-height: 26px;">(Integer&nbsp;groupId)</span>&nbsp;</span>{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="hljs-keyword" style="color: #569CD6; line-height: 26px;">this</span>.groupId&nbsp;=&nbsp;groupId;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="hljs-function" style="color: #DCDCDC; line-height: 26px;"><span class="hljs-keyword" style="color: #569CD6; line-height: 26px;">public</span>&nbsp;<span class="hljs-keyword" style="color: #569CD6; line-height: 26px;">void</span>&nbsp;<span class="hljs-title" style="color: #DCDCDC; line-height: 26px;">setSourceId</span><span class="hljs-params" style="color: #DCDCDC; line-height: 26px;">(Integer&nbsp;sourceId)</span>&nbsp;</span>{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="hljs-keyword" style="color: #569CD6; line-height: 26px;">this</span>.sourceId&nbsp;=&nbsp;sourceId;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;}<br></code></pre>
<h3 data-tool="mdnice编辑器" style="padding: 0px; color: black; font-size: 17px; font-weight: bold; text-align: center; position: relative; margin-top: 20px; margin-bottom: 20px;"><span class="prefix" style="display: none;"></span><span class="content" style="border-bottom: 2px solid RGBA(79, 177, 249, .65); color: #2b2b2b; padding-bottom: 2px;"><span style="width: 30px; height: 30px; display: block; background-image: url(https://my-wechat.mdnice.com/fullstack-2.png); background-position: center; background-size: 30px; margin: auto; opacity: 1; background-repeat: no-repeat; margin-bottom: -8px;"></span>测试</span><span class="suffix" style="display: none;"></span></h3>
<pre class="custom" data-tool="mdnice编辑器" style="margin-top: 10px; margin-bottom: 10px; border-radius: 5px; box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;"><span style="display: block; background: url(https://my-wechat.mdnice.com/point.png); height: 30px; width: 100%; background-size: 40px; background-repeat: no-repeat; background-color: #1E1E1E; margin-bottom: -7px; border-radius: 5px; background-position: 10px 10px;"></span><code class="hljs" style="overflow-x: auto; padding: 16px; color: #DCDCDC; display: -webkit-box; font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; font-size: 12px; -webkit-overflow-scrolling: touch; letter-spacing: 0px; padding-top: 15px; background: #1E1E1E; border-radius: 5px;"><span class="hljs-function" style="color: #DCDCDC; line-height: 26px;"><span class="hljs-keyword" style="color: #569CD6; line-height: 26px;">public</span>&nbsp;<span class="hljs-keyword" style="color: #569CD6; line-height: 26px;">static</span>&nbsp;<span class="hljs-keyword" style="color: #569CD6; line-height: 26px;">void</span>&nbsp;<span class="hljs-title" style="color: #DCDCDC; line-height: 26px;">main</span><span class="hljs-params" style="color: #DCDCDC; line-height: 26px;">(String[]&nbsp;args)</span>&nbsp;<span class="hljs-keyword" style="color: #569CD6; line-height: 26px;">throws</span>&nbsp;JAXBException&nbsp;</span>{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;RequetsXml&nbsp;root&nbsp;=&nbsp;<span class="hljs-keyword" style="color: #569CD6; line-height: 26px;">new</span>&nbsp;RequetsXml();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;root.setFileId(<span class="hljs-string" style="color: #D69D85; line-height: 26px;">"adsa45475454"</span>);<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CaseFile&nbsp;caseFile&nbsp;=&nbsp;<span class="hljs-keyword" style="color: #569CD6; line-height: 26px;">new</span>&nbsp;CaseFile();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;caseFile.setName(<span class="hljs-string" style="color: #D69D85; line-height: 26px;">"王凯"</span>);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;caseFile.setTmpFile(<span class="hljs-keyword" style="color: #569CD6; line-height: 26px;">false</span>);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;caseFile.setGroupId(<span class="hljs-number" style="color: #B8D7A3; line-height: 26px;">1</span>);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;caseFile.setSourceId(<span class="hljs-number" style="color: #B8D7A3; line-height: 26px;">0</span>);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;caseFile.setModifyTimStamp(<span class="hljs-string" style="color: #D69D85; line-height: 26px;">"1575454212"</span>);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;root.setCaseFile(caseFile);<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;JAXBContext&nbsp;context&nbsp;=&nbsp;JAXBContext.newInstance(RequetsXml.class);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Marshaller&nbsp;m&nbsp;=&nbsp;context.createMarshaller();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT,&nbsp;Boolean.TRUE);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;m.marshal(root,&nbsp;System.out);<br><br>&nbsp;&nbsp;&nbsp;&nbsp;}<br><br></code></pre>
<h3 data-tool="mdnice编辑器" style="padding: 0px; color: black; font-size: 17px; font-weight: bold; text-align: center; position: relative; margin-top: 20px; margin-bottom: 20px;"><span class="prefix" style="display: none;"></span><span class="content" style="border-bottom: 2px solid RGBA(79, 177, 249, .65); color: #2b2b2b; padding-bottom: 2px;"><span style="width: 30px; height: 30px; display: block; background-image: url(https://my-wechat.mdnice.com/fullstack-2.png); background-position: center; background-size: 30px; margin: auto; opacity: 1; background-repeat: no-repeat; margin-bottom: -8px;"></span>输出</span><span class="suffix" style="display: none;"></span></h3>
<pre class="custom" data-tool="mdnice编辑器" style="margin-top: 10px; margin-bottom: 10px; border-radius: 5px; box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;"><span style="display: block; background: url(https://my-wechat.mdnice.com/point.png); height: 30px; width: 100%; background-size: 40px; background-repeat: no-repeat; background-color: #1E1E1E; margin-bottom: -7px; border-radius: 5px; background-position: 10px 10px;"></span><code class="hljs" style="overflow-x: auto; padding: 16px; color: #DCDCDC; display: -webkit-box; font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; font-size: 12px; -webkit-overflow-scrolling: touch; letter-spacing: 0px; padding-top: 15px; background: #1E1E1E; border-radius: 5px;"><span class="hljs-meta" style="color: #9B9B9B; line-height: 26px;">&lt;?xml&nbsp;version="1.0"&nbsp;encoding="UTF-8"&nbsp;standalone="yes"?&gt;</span><br><span class="hljs-tag" style="color: #9B9B9B; line-height: 26px;">&lt;<span class="hljs-name" style="color: #569CD6; line-height: 26px;">request</span>&gt;</span><br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="hljs-tag" style="color: #9B9B9B; line-height: 26px;">&lt;<span class="hljs-name" style="color: #569CD6; line-height: 26px;">casefile</span>&gt;</span><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="hljs-tag" style="color: #9B9B9B; line-height: 26px;">&lt;<span class="hljs-name" style="color: #569CD6; line-height: 26px;">name</span>&gt;</span>王凯<span class="hljs-tag" style="color: #9B9B9B; line-height: 26px;">&lt;/<span class="hljs-name" style="color: #569CD6; line-height: 26px;">name</span>&gt;</span><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="hljs-tag" style="color: #9B9B9B; line-height: 26px;">&lt;<span class="hljs-name" style="color: #569CD6; line-height: 26px;">isTmpFile</span>&gt;</span>false<span class="hljs-tag" style="color: #9B9B9B; line-height: 26px;">&lt;/<span class="hljs-name" style="color: #569CD6; line-height: 26px;">isTmpFile</span>&gt;</span><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="hljs-tag" style="color: #9B9B9B; line-height: 26px;">&lt;<span class="hljs-name" style="color: #569CD6; line-height: 26px;">modify-timestamp</span>&gt;</span>1575454212<span class="hljs-tag" style="color: #9B9B9B; line-height: 26px;">&lt;/<span class="hljs-name" style="color: #569CD6; line-height: 26px;">modify-timestamp</span>&gt;</span><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="hljs-tag" style="color: #9B9B9B; line-height: 26px;">&lt;<span class="hljs-name" style="color: #569CD6; line-height: 26px;">sdb-group-id</span>&gt;</span>1<span class="hljs-tag" style="color: #9B9B9B; line-height: 26px;">&lt;/<span class="hljs-name" style="color: #569CD6; line-height: 26px;">sdb-group-id</span>&gt;</span><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="hljs-tag" style="color: #9B9B9B; line-height: 26px;">&lt;<span class="hljs-name" style="color: #569CD6; line-height: 26px;">source-system-id</span>&gt;</span>0<span class="hljs-tag" style="color: #9B9B9B; line-height: 26px;">&lt;/<span class="hljs-name" style="color: #569CD6; line-height: 26px;">source-system-id</span>&gt;</span><br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="hljs-tag" style="color: #9B9B9B; line-height: 26px;">&lt;/<span class="hljs-name" style="color: #569CD6; line-height: 26px;">casefile</span>&gt;</span><br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="hljs-tag" style="color: #9B9B9B; line-height: 26px;">&lt;<span class="hljs-name" style="color: #569CD6; line-height: 26px;">uploaded-file-id</span>&gt;</span>adsa45475454<span class="hljs-tag" style="color: #9B9B9B; line-height: 26px;">&lt;/<span class="hljs-name" style="color: #569CD6; line-height: 26px;">uploaded-file-id</span>&gt;</span><br><span class="hljs-tag" style="color: #9B9B9B; line-height: 26px;">&lt;/<span class="hljs-name" style="color: #569CD6; line-height: 26px;">request</span>&gt;</span><br></code></pre>
<h3 data-tool="mdnice编辑器" style="padding: 0px; color: black; font-size: 17px; font-weight: bold; text-align: center; position: relative; margin-top: 20px; margin-bottom: 20px;"><span class="prefix" style="display: none;"></span><span class="content" style="border-bottom: 2px solid RGBA(79, 177, 249, .65); color: #2b2b2b; padding-bottom: 2px;"><span style="width: 30px; height: 30px; display: block; background-image: url(https://my-wechat.mdnice.com/fullstack-2.png); background-position: center; background-size: 30px; margin: auto; opacity: 1; background-repeat: no-repeat; margin-bottom: -8px;"></span>工具类封装</span><span class="suffix" style="display: none;"></span></h3>
<pre class="custom" data-tool="mdnice编辑器" style="margin-top: 10px; margin-bottom: 10px; border-radius: 5px; box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;"><span style="display: block; background: url(https://my-wechat.mdnice.com/point.png); height: 30px; width: 100%; background-size: 40px; background-repeat: no-repeat; background-color: #1E1E1E; margin-bottom: -7px; border-radius: 5px; background-position: 10px 10px;"></span><code class="hljs" style="overflow-x: auto; padding: 16px; color: #DCDCDC; display: -webkit-box; font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; font-size: 12px; -webkit-overflow-scrolling: touch; letter-spacing: 0px; padding-top: 15px; background: #1E1E1E; border-radius: 5px;"><span class="hljs-keyword" style="color: #569CD6; line-height: 26px;">import</span>&nbsp;com.alibaba.fastjson.JSON;<br><span class="hljs-keyword" style="color: #569CD6; line-height: 26px;">import</span>&nbsp;com.alibaba.fastjson.JSONObject;<br><span class="hljs-keyword" style="color: #569CD6; line-height: 26px;">import</span>&nbsp;org.json.JSONException;<br><span class="hljs-keyword" style="color: #569CD6; line-height: 26px;">import</span>&nbsp;org.json.XML;<br><br><span class="hljs-keyword" style="color: #569CD6; line-height: 26px;">import</span>&nbsp;java.io.StringReader;<br><span class="hljs-keyword" style="color: #569CD6; line-height: 26px;">import</span>&nbsp;java.io.StringWriter;<br><span class="hljs-keyword" style="color: #569CD6; line-height: 26px;">import</span>&nbsp;javax.xml.bind.JAXBContext;<br><span class="hljs-keyword" style="color: #569CD6; line-height: 26px;">import</span>&nbsp;javax.xml.bind.Marshaller;<br><span class="hljs-keyword" style="color: #569CD6; line-height: 26px;">import</span>&nbsp;javax.xml.bind.Unmarshaller;<br><br><span class="hljs-comment" style="color: #57A64A; font-style: italic; line-height: 26px;">/**<br>&nbsp;*<br>&nbsp;*&nbsp;Class&nbsp;Name:&nbsp;XmlConvertUtil<br>&nbsp;*&nbsp;Description:&nbsp;xml格式转化工具类<br>&nbsp;*<br>&nbsp;*/</span><br><span class="hljs-keyword" style="color: #569CD6; line-height: 26px;">public</span>&nbsp;<span class="hljs-class" style="color: #B8D7A3; line-height: 26px;"><span class="hljs-keyword" style="color: #569CD6; line-height: 26px;">class</span>&nbsp;<span class="hljs-title" style="color: #DCDCDC; line-height: 26px;">XmlConvertUtil</span>&nbsp;</span>{<br>&nbsp;<span class="hljs-comment" style="color: #57A64A; font-style: italic; line-height: 26px;">/**<br>&nbsp;&nbsp;*&nbsp;xml转换成JavaBean<br>&nbsp;&nbsp;*<br>&nbsp;&nbsp;*&nbsp;<span class="hljs-doctag" style="color: #608B4E; line-height: 26px;">@param</span>&nbsp;xml&nbsp;xml格式字符串<br>&nbsp;&nbsp;*&nbsp;<span class="hljs-doctag" style="color: #608B4E; line-height: 26px;">@param</span>&nbsp;t&nbsp;待转化的对象<br>&nbsp;&nbsp;*&nbsp;<span class="hljs-doctag" style="color: #608B4E; line-height: 26px;">@return</span>&nbsp;转化后的对象<br>&nbsp;&nbsp;*&nbsp;<span class="hljs-doctag" style="color: #608B4E; line-height: 26px;">@throws</span>&nbsp;Exception&nbsp;JAXBException<br>&nbsp;&nbsp;*/</span><br>&nbsp;<span class="hljs-meta" style="color: #9B9B9B; line-height: 26px;">@SuppressWarnings</span>({&nbsp;<span class="hljs-string" style="color: #D69D85; line-height: 26px;">"unchecked"</span>&nbsp;})<br>&nbsp;<span class="hljs-keyword" style="color: #569CD6; line-height: 26px;">public</span>&nbsp;<span class="hljs-keyword" style="color: #569CD6; line-height: 26px;">static</span>&nbsp;&lt;T&gt;&nbsp;<span class="hljs-function" style="color: #DCDCDC; line-height: 26px;">T&nbsp;<span class="hljs-title" style="color: #DCDCDC; line-height: 26px;">convertToJavaBean</span><span class="hljs-params" style="color: #DCDCDC; line-height: 26px;">(String&nbsp;xml,&nbsp;Class&lt;T&gt;&nbsp;t)</span>&nbsp;<span class="hljs-keyword" style="color: #569CD6; line-height: 26px;">throws</span>&nbsp;Exception&nbsp;</span>{<br>&nbsp;&nbsp;T&nbsp;obj&nbsp;=&nbsp;<span class="hljs-keyword" style="color: #569CD6; line-height: 26px;">null</span>;<br>&nbsp;&nbsp;JAXBContext&nbsp;context&nbsp;=&nbsp;JAXBContext.newInstance(t);<br>&nbsp;&nbsp;Unmarshaller&nbsp;unmarshaller&nbsp;=&nbsp;context.createUnmarshaller();<br>&nbsp;&nbsp;obj&nbsp;=&nbsp;(T)&nbsp;unmarshaller.unmarshal(<span class="hljs-keyword" style="color: #569CD6; line-height: 26px;">new</span>&nbsp;StringReader(xml));<br>&nbsp;&nbsp;<span class="hljs-keyword" style="color: #569CD6; line-height: 26px;">return</span>&nbsp;obj;<br>&nbsp;}<br><br>&nbsp;<span class="hljs-comment" style="color: #57A64A; font-style: italic; line-height: 26px;">/**<br>&nbsp;&nbsp;*&nbsp;JavaBean转换成xml<br>&nbsp;&nbsp;*&nbsp;<span class="hljs-doctag" style="color: #608B4E; line-height: 26px;">@param</span>&nbsp;obj<br>&nbsp;&nbsp;*&nbsp;<span class="hljs-doctag" style="color: #608B4E; line-height: 26px;">@param</span>&nbsp;encoding<br>&nbsp;&nbsp;*&nbsp;<span class="hljs-doctag" style="color: #608B4E; line-height: 26px;">@return</span><br>&nbsp;&nbsp;*/</span><br>&nbsp;<span class="hljs-function" style="color: #DCDCDC; line-height: 26px;"><span class="hljs-keyword" style="color: #569CD6; line-height: 26px;">public</span>&nbsp;<span class="hljs-keyword" style="color: #569CD6; line-height: 26px;">static</span>&nbsp;String&nbsp;<span class="hljs-title" style="color: #DCDCDC; line-height: 26px;">convertToXml</span><span class="hljs-params" style="color: #DCDCDC; line-height: 26px;">(Object&nbsp;obj,&nbsp;String&nbsp;encoding)</span>&nbsp;</span>{<br>&nbsp;&nbsp;String&nbsp;result&nbsp;=&nbsp;<span class="hljs-keyword" style="color: #569CD6; line-height: 26px;">null</span>;<br>&nbsp;&nbsp;<span class="hljs-keyword" style="color: #569CD6; line-height: 26px;">try</span>&nbsp;{<br>&nbsp;&nbsp;&nbsp;JAXBContext&nbsp;context&nbsp;=&nbsp;JAXBContext.newInstance(obj.getClass());<br>&nbsp;&nbsp;&nbsp;Marshaller&nbsp;marshaller&nbsp;=&nbsp;context.createMarshaller();<br>&nbsp;&nbsp;&nbsp;marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT,&nbsp;<span class="hljs-keyword" style="color: #569CD6; line-height: 26px;">true</span>);<br>&nbsp;&nbsp;&nbsp;marshaller.setProperty(Marshaller.JAXB_ENCODING,&nbsp;encoding);<br><br>&nbsp;&nbsp;&nbsp;StringWriter&nbsp;writer&nbsp;=&nbsp;<span class="hljs-keyword" style="color: #569CD6; line-height: 26px;">new</span>&nbsp;StringWriter();<br>&nbsp;&nbsp;&nbsp;marshaller.marshal(obj,&nbsp;writer);<br>&nbsp;&nbsp;&nbsp;result&nbsp;=&nbsp;writer.toString();<br>&nbsp;&nbsp;}&nbsp;<span class="hljs-keyword" style="color: #569CD6; line-height: 26px;">catch</span>&nbsp;(Exception&nbsp;e)&nbsp;{<br>&nbsp;&nbsp;&nbsp;e.printStackTrace();<br>&nbsp;&nbsp;}<br><br>&nbsp;&nbsp;<span class="hljs-keyword" style="color: #569CD6; line-height: 26px;">return</span>&nbsp;result;<br>&nbsp;}<br><br>&nbsp;<span class="hljs-function" style="color: #DCDCDC; line-height: 26px;"><span class="hljs-keyword" style="color: #569CD6; line-height: 26px;">public</span>&nbsp;<span class="hljs-keyword" style="color: #569CD6; line-height: 26px;">static</span>&nbsp;JSONObject&nbsp;<span class="hljs-title" style="color: #DCDCDC; line-height: 26px;">xmlToJson</span><span class="hljs-params" style="color: #DCDCDC; line-height: 26px;">(String&nbsp;xml)</span>&nbsp;</span>{<br>&nbsp;&nbsp;<span class="hljs-keyword" style="color: #569CD6; line-height: 26px;">try</span>&nbsp;{<br>&nbsp;&nbsp;&nbsp;org.json.JSONObject&nbsp;object&nbsp;=&nbsp;XML.toJSONObject(xml);<br>&nbsp;&nbsp;&nbsp;String&nbsp;jsonData&nbsp;=&nbsp;object.get(<span class="hljs-string" style="color: #D69D85; line-height: 26px;">"response"</span>).toString();<br>&nbsp;&nbsp;&nbsp;JSONObject&nbsp;jsonObject&nbsp;=&nbsp;JSON.parseObject(jsonData);<br>&nbsp;&nbsp;&nbsp;<span class="hljs-keyword" style="color: #569CD6; line-height: 26px;">return</span>&nbsp;jsonObject;<br>&nbsp;&nbsp;&nbsp;<span class="hljs-comment" style="color: #57A64A; font-style: italic; line-height: 26px;">/*JSONObject&nbsp;result&nbsp;=&nbsp;(JSONObject)&nbsp;jsonObject.get("result");<br>&nbsp;&nbsp;&nbsp;JSONObject&nbsp;upload&nbsp;=&nbsp;(JSONObject)&nbsp;result.get("upload");<br>&nbsp;&nbsp;&nbsp;String&nbsp;uploadUrl&nbsp;=&nbsp;upload.get("url").toString();<br>&nbsp;&nbsp;&nbsp;String&nbsp;fildId&nbsp;=&nbsp;upload.get("upload-file-id").toString();*/</span><br>&nbsp;&nbsp;}&nbsp;<span class="hljs-keyword" style="color: #569CD6; line-height: 26px;">catch</span>&nbsp;(JSONException&nbsp;e)&nbsp;{<br>&nbsp;&nbsp;&nbsp;e.printStackTrace();<br>&nbsp;&nbsp;&nbsp;<span class="hljs-keyword" style="color: #569CD6; line-height: 26px;">return</span>&nbsp;<span class="hljs-keyword" style="color: #569CD6; line-height: 26px;">null</span>;<br>&nbsp;&nbsp;}<br>&nbsp;}<br>}<br></code></pre>
<p data-tool="mdnice编辑器" style="padding-top: 8px; padding-bottom: 8px; line-height: 26px; color: #2b2b2b; margin: 10px 0px; letter-spacing: 2px; font-size: 14px; word-spacing: 2px;"><span style="color:red;">切记,实体类中的@XmlRootElement注解不可一省略,否则会抛异常</span></p>
<h3 data-tool="mdnice编辑器" style="padding: 0px; color: black; font-size: 17px; font-weight: bold; text-align: center; position: relative; margin-top: 20px; margin-bottom: 20px;"><span class="prefix" style="display: none;"></span><span class="content" style="border-bottom: 2px solid RGBA(79, 177, 249, .65); color: #2b2b2b; padding-bottom: 2px;"><span style="width: 30px; height: 30px; display: block; background-image: url(https://my-wechat.mdnice.com/fullstack-2.png); background-position: center; background-size: 30px; margin: auto; opacity: 1; background-repeat: no-repeat; margin-bottom: -8px;"></span>[特别重要] 补充一下,加上get方法之后,如果出现报错,在get方法上面添加注解<code>@XmlTransient</code></span><span class="suffix" style="display: none;"></span></h3>
</section>

      
      <!-- reward -->
      
      <div id="reward-btn">
        Donate
      </div>
      
    </div>
    
    
      <!-- copyright -->
      
        <div class="declare">
          <ul class="post-copyright">
            <li>
              <i class="ri-copyright-line"></i>
              <strong>Copyright： </strong>
              Copyright is owned by the author. For commercial reprints, please contact the author for authorization. For non-commercial reprints, please indicate the source.
            </li>
          </ul>
        </div>
        
    <footer class="article-footer">
      
          
<div class="share-btn">
      <span class="share-sns share-outer">
        <i class="ri-share-forward-line"></i>
        分享
      </span>
      <div class="share-wrap">
        <i class="arrow"></i>
        <div class="share-icons">
          
          <a class="weibo share-sns" href="javascript:;" data-type="weibo">
            <i class="ri-weibo-fill"></i>
          </a>
          <a class="weixin share-sns wxFab" href="javascript:;" data-type="weixin">
            <i class="ri-wechat-fill"></i>
          </a>
          <a class="qq share-sns" href="javascript:;" data-type="qq">
            <i class="ri-qq-fill"></i>
          </a>
          <a class="douban share-sns" href="javascript:;" data-type="douban">
            <i class="ri-douban-line"></i>
          </a>
          <!-- <a class="qzone share-sns" href="javascript:;" data-type="qzone">
            <i class="icon icon-qzone"></i>
          </a> -->
          
          <a class="facebook share-sns" href="javascript:;" data-type="facebook">
            <i class="ri-facebook-circle-fill"></i>
          </a>
          <a class="twitter share-sns" href="javascript:;" data-type="twitter">
            <i class="ri-twitter-fill"></i>
          </a>
          <a class="google share-sns" href="javascript:;" data-type="google">
            <i class="ri-google-fill"></i>
          </a>
        </div>
      </div>
</div>

<div class="wx-share-modal">
    <a class="modal-close" href="javascript:;"><i class="ri-close-circle-line"></i></a>
    <p>扫一扫，分享到微信</p>
    <div class="wx-qrcode">
      <img src="//api.qrserver.com/v1/create-qr-code/?size=150x150&data=https://bodboy.gitee.io/blog/2020/09/04/XmlRootElement%E7%9A%84%E4%BD%9C%E7%94%A8%E5%92%8C%E7%94%A8%E6%B3%95/" alt="微信分享二维码">
    </div>
</div>

<div id="share-mask"></div>
      
      
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/blog/tags/XmlRootElement/" rel="tag">XmlRootElement</a></li></ul>


    </footer>

  </div>

  
  
  <nav class="article-nav">
    
      <a href="/blog/2020/09/08/java%E6%95%B4%E5%90%88FastDFS%E6%96%87%E4%BB%B6%E6%9C%8D%E5%8A%A1%E5%99%A8/" class="article-nav-link">
        <strong class="article-nav-caption">上一篇</strong>
        <div class="article-nav-title">
          
            java整合FastDFS文件服务器
          
        </div>
      </a>
    
    
      <a href="/blog/2020/09/04/%E5%B0%86InputSteram%E8%BD%AC%E6%8D%A2%E6%88%90%E6%96%87%E4%BB%B6%E8%BE%93%E5%87%BA%E5%B9%B6%E4%B8%8B%E8%BD%BD%E8%87%B3%E6%9C%AC%E5%9C%B0/" class="article-nav-link">
        <strong class="article-nav-caption">下一篇</strong>
        <div class="article-nav-title">将InputSteram转换成文件输出并下载至本地</div>
      </a>
    
  </nav>


  

  
  
<!-- valine评论 -->
<div id="vcomments-box">
    <div id="vcomments">
    </div>
</div>
<script src="//cdn1.lncld.net/static/js/3.0.4/av-min.js"></script>
<script src='https://cdn.jsdelivr.net/npm/valine@1.3.10/dist/Valine.min.js'></script>
<script>
    new Valine({
        el: '#vcomments',
        app_id: 'uW8QYGvvhWmNWdiwpznJ0GVa-gzGzoHsz',
        app_key: 'LrJhMzx9qEwcMV1DJjTI6f6C',
        path: window.location.pathname,
        notify: 'false',
        verify: 'false',
        avatar: '[object Object]',
        placeholder: '给我的文章加点评论吧~',
        recordIP: true
    });
    const infoEle = document.querySelector('#vcomments .info');
    if (infoEle && infoEle.childNodes && infoEle.childNodes.length > 0) {
        infoEle.childNodes.forEach(function (item) {
            item.parentNode.removeChild(item);
        });
    }
</script>
<style>
    #vcomments-box {
        padding: 5px 30px;
    }

    @media screen and (max-width: 800px) {
        #vcomments-box {
            padding: 5px 0px;
        }
    }

    #vcomments-box #vcomments {
        background-color: #fff;
    }

    .v .vlist .vcard .vh {
        padding-right: 20px;
    }

    .v .vlist .vcard {
        padding-left: 10px;
    }
</style>

  

  
  
  
  
  

</article>
</section>
      <footer class="footer">
  <div class="outer">
    <ul>
      <li>
        Copyrights &copy;
        2019-2021
        <i class="ri-heart-fill heart_icon"></i> panda
      </li>
    </ul>
    <ul>
      <li>
        
        
        
        Powered by <a href="https://hexo.io" target="_blank">Hexo</a>
        <span class="division">|</span>
        Theme - <a href="https://github.com/Shen-Yu/hexo-theme-ayer" target="_blank">Ayer</a>
        
      </li>
    </ul>
    <ul>
      <li>
        
        
        <span>
  <span><i class="ri-user-3-fill"></i>Visitors:<span id="busuanzi_value_site_uv"></span></s>
  <span class="division">|</span>
  <span><i class="ri-eye-fill"></i>Views:<span id="busuanzi_value_page_pv"></span></span>
</span>
        
      </li>
    </ul>
    <ul>
      
    </ul>
    <ul>
      <li>
        <!-- cnzz统计 -->
        
        <script type="text/javascript" src='https://s9.cnzz.com/z_stat.php?id=1278069914&amp;web_id=1278069914'></script>
        
      </li>
    </ul>
  </div>
</footer>
      <div class="float_btns">
        <div class="totop" id="totop">
  <i class="ri-arrow-up-line"></i>
</div>

<div class="todark" id="todark">
  <i class="ri-moon-line"></i>
</div>

      </div>
    </main>
    <aside class="sidebar on">
      <button class="navbar-toggle"></button>
<nav class="navbar">
  
  <div class="logo">
    <a href="/blog/"><img src="https://portrait.gitee.com/uploads/avatars/user/1007/3023420_bodboy_1578973210.png!avatar200" alt="小熊的博客"></a>
  </div>
  
  <ul class="nav nav-main">
    
    <li class="nav-item">
      <a class="nav-item-link" href="/blog/">主页</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/blog/archives">归档</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/blog/categories">分类</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/blog/tags">标签</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/blog/tags/%E6%97%85%E8%A1%8C/">旅行</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/blog/about">关于我</a>
    </li>
    
  </ul>
</nav>
<nav class="navbar navbar-bottom">
  <ul class="nav">
    <li class="nav-item">
      
      <a class="nav-item-link nav-item-search"  title="Search">
        <i class="ri-search-line"></i>
      </a>
      
      
      <a class="nav-item-link" target="_blank" href="/blog/atom.xml" title="RSS Feed">
        <i class="ri-rss-line"></i>
      </a>
      
    </li>
  </ul>
</nav>
<div class="search-form-wrap">
  <div class="local-search local-search-plugin">
  <input type="search" id="local-search-input" class="local-search-input" placeholder="Search...">
  <div id="local-search-result" class="local-search-result"></div>
</div>
</div>
    </aside>
    <script>
      if (window.matchMedia("(max-width: 768px)").matches) {
        document.querySelector('.content').classList.remove('on');
        document.querySelector('.sidebar').classList.remove('on');
      }
    </script>
    <div id="mask"></div>

<!-- #reward -->
<div id="reward">
  <span class="close"><i class="ri-close-line"></i></span>
  <p class="reward-p"><i class="ri-cup-line"></i>请我喝杯咖啡吧~</p>
  <div class="reward-box">
    
    <div class="reward-item">
      <img class="reward-img" src="/blog/images/alipay.jpg">
      <span class="reward-type">支付宝</span>
    </div>
    
    
    <div class="reward-item">
      <img class="reward-img" src="/blog/images/wechat.jpg">
      <span class="reward-type">微信</span>
    </div>
    
  </div>
</div>
    
<script src="/blog/js/jquery-2.0.3.min.js"></script>


<script src="/blog/js/lazyload.min.js"></script>


<script>
  try {
    var typed = new Typed("#subtitle", {
      strings: ['面朝大海，春暖花开', '愿你一生努力，一生被爱', '想要的都拥有，得不到的都释怀'],
      startDelay: 0,
      typeSpeed: 200,
      loop: true,
      backSpeed: 100,
      showCursor: true
    });
  } catch (err) {
  }

</script>




<script src="/blog/js/tocbot.min.js"></script>

<script>
  // Tocbot_v4.7.0  http://tscanlin.github.io/tocbot/
  tocbot.init({
    tocSelector: '.tocbot',
    contentSelector: '.article-entry',
    headingSelector: 'h1, h2, h3, h4, h5, h6',
    hasInnerContainers: true,
    scrollSmooth: true,
    scrollContainer: 'main',
    positionFixedSelector: '.tocbot',
    positionFixedClass: 'is-position-fixed',
    fixedSidebarOffset: 'auto'
  });
</script>



<script src="https://cdn.jsdelivr.net/npm/jquery-modal@0.9.2/jquery.modal.min.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/jquery-modal@0.9.2/jquery.modal.min.css">
<script src="https://cdn.jsdelivr.net/npm/justifiedGallery@3.7.0/dist/js/jquery.justifiedGallery.min.js"></script>

<script src="/blog/dist/main.js"></script>



<!-- Root element of PhotoSwipe. Must have class pswp. -->
<div class="pswp" tabindex="-1" role="dialog" aria-hidden="true">

    <!-- Background of PhotoSwipe. 
         It's a separate element as animating opacity is faster than rgba(). -->
    <div class="pswp__bg"></div>

    <!-- Slides wrapper with overflow:hidden. -->
    <div class="pswp__scroll-wrap">

        <!-- Container that holds slides. 
            PhotoSwipe keeps only 3 of them in the DOM to save memory.
            Don't modify these 3 pswp__item elements, data is added later on. -->
        <div class="pswp__container">
            <div class="pswp__item"></div>
            <div class="pswp__item"></div>
            <div class="pswp__item"></div>
        </div>

        <!-- Default (PhotoSwipeUI_Default) interface on top of sliding area. Can be changed. -->
        <div class="pswp__ui pswp__ui--hidden">

            <div class="pswp__top-bar">

                <!--  Controls are self-explanatory. Order can be changed. -->

                <div class="pswp__counter"></div>

                <button class="pswp__button pswp__button--close" title="Close (Esc)"></button>

                <button class="pswp__button pswp__button--share" style="display:none" title="Share"></button>

                <button class="pswp__button pswp__button--fs" title="Toggle fullscreen"></button>

                <button class="pswp__button pswp__button--zoom" title="Zoom in/out"></button>

                <!-- Preloader demo http://codepen.io/dimsemenov/pen/yyBWoR -->
                <!-- element will get class pswp__preloader--active when preloader is running -->
                <div class="pswp__preloader">
                    <div class="pswp__preloader__icn">
                        <div class="pswp__preloader__cut">
                            <div class="pswp__preloader__donut"></div>
                        </div>
                    </div>
                </div>
            </div>

            <div class="pswp__share-modal pswp__share-modal--hidden pswp__single-tap">
                <div class="pswp__share-tooltip"></div>
            </div>

            <button class="pswp__button pswp__button--arrow--left" title="Previous (arrow left)">
            </button>

            <button class="pswp__button pswp__button--arrow--right" title="Next (arrow right)">
            </button>

            <div class="pswp__caption">
                <div class="pswp__caption__center"></div>
            </div>

        </div>

    </div>

</div>

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/photoswipe.min.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/default-skin/default-skin.min.css">
<script src="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/photoswipe.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/photoswipe-ui-default.min.js"></script>

<script>
    function viewer_init() {
        let pswpElement = document.querySelectorAll('.pswp')[0];
        let $imgArr = document.querySelectorAll(('.article-entry img:not(.reward-img)'))

        $imgArr.forEach(($em, i) => {
            $em.onclick = () => {
                // slider展开状态
                // todo: 这样不好，后面改成状态
                if (document.querySelector('.left-col.show')) return
                let items = []
                $imgArr.forEach(($em2, i2) => {
                    let img = $em2.getAttribute('data-idx', i2)
                    let src = $em2.getAttribute('data-target') || $em2.getAttribute('src')
                    let title = $em2.getAttribute('alt')
                    // 获得原图尺寸
                    const image = new Image()
                    image.src = src
                    items.push({
                        src: src,
                        w: image.width || $em2.width,
                        h: image.height || $em2.height,
                        title: title
                    })
                })
                var gallery = new PhotoSwipe(pswpElement, PhotoSwipeUI_Default, items, {
                    index: parseInt(i)
                });
                gallery.init()
            }
        })
    }
    viewer_init()
</script>


<script type="text/x-mathjax-config">
  MathJax.Hub.Config({
      tex2jax: {
          inlineMath: [ ['$','$'], ["\\(","\\)"]  ],
          processEscapes: true,
          skipTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code']
      }
  });

  MathJax.Hub.Queue(function() {
      var all = MathJax.Hub.getAllJax(), i;
      for(i=0; i < all.length; i += 1) {
          all[i].SourceElement().parentNode.className += ' has-jax';
      }
  });
</script>

<script src="https://cdn.jsdelivr.net/npm/mathjax@2.7.6/unpacked/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
<script>
  var ayerConfig = {
    mathjax: true
  }
</script>




<script src="/blog/js/busuanzi-2.3.pure.min.js"></script>



<script type="text/javascript" src="https://js.users.51.la/20544303.js"></script>

  
<script src="/blog/js/clickLove.js"></script>



<!-- 复制 -->



    
    <div id="music">
    
    
    
    <iframe frameborder="no" border="1" marginwidth="0" marginheight="0" width="200" height="52"
        src="//music.163.com/outchain/player?type=2&id=1297802566&auto=1&height=32"></iframe>
</div>

<style>
    #music {
        position: fixed;
        right: 15px;
        bottom: 0;
        z-index: 998;
    }
</style>
    
  </div>
</body>

</html>